package org.tong.jpa.service.inter;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.tong.jpa.entities.Student;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.concurrent.ExecutionException;

/**
 * @author
 * @date 2022-08-01 17:37
 */
public interface StudentService {

    @Cacheable(value = "student", key = "#id")
    Student findById(@Valid @NotNull Long id);

    @CacheEvict(value = "student", key = "#id")
    void deleteById(@Valid @NotNull Long id);

    @CacheEvict(value = "student", key = "#student.id")
    void update(Student student);

    @CacheEvict(value = "student", key = "#student.id")
    Long save(Student student);

    Student saveAndFind(Student student) throws ExecutionException, InterruptedException;

    List<Student> findAll();

    void saveAll(Student... students);
}
